Skip to content

Add document type (normtyp) as metadata#39

Merged
marcarl merged 3 commits into
mainfrom
feature/add-normtyp-to-frontmatter
Jan 7, 2026
Merged

Add document type (normtyp) as metadata#39
marcarl merged 3 commits into
mainfrom
feature/add-normtyp-to-frontmatter

Conversation

@marcarl
Copy link
Copy Markdown
Collaborator

@marcarl marcarl commented Jan 7, 2026

Summary

This PR adds support for classifying SFS documents by their legal type (doctype) with three categories:

  • Grundlag (Fundamental law) - Sweden's four constitutional laws
  • Lag (Law) - Regular laws
  • Förordning (Regulation) - Regulations

Changes

  • ✨ Add util/doctype_utils.py with determine_doctype() function
  • 🔍 Identify Sweden's four fundamental laws by SFS number (1974:152, 1810:0926, 1949:105, 1991:1469)
  • 📝 Integrate doctype into markdown frontmatter generation (after departement field)
  • 🌐 Add doctype to HTML export metadata display
  • 🔄 Update frontmatter property ordering to include doctype
  • 📝 Use English key "doctype" for consistency in code and filenames

Implementation Details

The doctype is determined by:

  1. First checking if the SFS number matches one of the four grundlagar
  2. If not, using the forfattningstypNamn field from source data
  3. Defaulting to "Lag" if no explicit type information is available

Field key uses English ("doctype") while values remain in Swedish (Grundlag, Lag, Förordning) as these are the official Swedish legal terms.

Test Results

  • ✅ 1974:152 (Regeringsformen) → doctype: Grundlag
  • ✅ 2010:800 (Skollagen) → doctype: Lag
  • ✅ 2024:1274 → doctype: Förordning

🤖 Generated with Claude Code

marcarl and others added 2 commits January 7, 2026 10:51
This commit adds support for classifying SFS documents by their legal
type (normtyp) with three categories: Grundlag, Lag, and Förordning.

Changes:
- Add util/normtyp_utils.py with determine_normtyp() function
- Identify Sweden's four fundamental laws (grundlagar) by SFS number
- Integrate normtyp into markdown frontmatter generation
- Add normtyp to HTML export metadata display
- Update frontmatter property ordering to include normtyp

The normtyp field appears after departement in frontmatter and is
determined by checking if the document is a grundlag, then using the
forfattningstypNamn field from source data to distinguish between
regular laws and regulations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed from Swedish "normtyp" to English "doctype" for better
consistency in filenames, variable names, and frontmatter keys.

Changes:
- Rename util/normtyp_utils.py to util/doctype_utils.py
- Rename determine_normtyp() to determine_doctype()
- Update frontmatter key from "normtyp" to "doctype"
- Update HTML metadata label from "Normtyp" to "Doctype"
- Update all imports and references throughout codebase

The field values remain in Swedish (Grundlag, Lag, Förordning) as
these are the official Swedish legal terms.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@marcarl marcarl changed the title Add normtyp field to frontmatter and HTML export Add doctype field to frontmatter and HTML export Jan 7, 2026
@marcarl marcarl changed the title Add doctype field to frontmatter and HTML export Add doc type as metadata Jan 7, 2026
@marcarl marcarl changed the title Add doc type as metadata Add doc type (normtyp) as metadata Jan 7, 2026
@marcarl marcarl changed the title Add doc type (normtyp) as metadata Add document type (normtyp) as metadata Jan 7, 2026
While internal code uses 'doctype' for clarity, the frontmatter key
and HTML display should use the Swedish term 'normtyp' to match
Swedish legal terminology and user expectations.

Changes:
- Frontmatter key: doctype → normtyp
- HTML display label: "Doctype" → "Normtyp"
- Property sort order: normtyp positioned before departement

Internal code (functions, variables) continues to use 'doctype'.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@marcarl marcarl merged commit f6a3f34 into main Jan 7, 2026
5 checks passed
@marcarl marcarl deleted the feature/add-normtyp-to-frontmatter branch January 7, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant